<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
function sureTransfer(from, to, all) {
	if ( from.getElementsByTagName && to.appendChild ) {
		while ( getCount(from, !all) > 0 ) {
			transfer(from, to, all);
		}
	}
}
function getCount(target, isSelected) {
	var options = target.getElementsByTagName("option");
	if ( !isSelected ) {
		return options.length;
	}
	var count = 0;
	for ( i = 0; i < options.length; i++ ) {
		if ( isSelected && options[i].selected ) {
			count++;
		}
	}
	return count;
}
function transfer(from, to, all) {
	if ( from.getElementsByTagName && to.appendChild ) {
		var options = from.getElementsByTagName("option");
		for ( i = 0; i < options.length; i++ ) {
			if ( all ) {
				to.appendChild(options[i]);
			} 
			else {
				if ( options[i].selected ) {
					to.appendChild(options[i]);
				}
			}
		}
	}
}
window.onload = function() {
document.getElementById("src2TargetAll").onclick = function() {
sureTransfer(document.getElementById("source"), document.getElementById("target"), true);
};
document.getElementById("src2Target").onclick = function() {
sureTransfer(document.getElementById("source"), document.getElementById("target"), false);
};
document.getElementById("target2SrcAll").onclick = function() {
sureTransfer(document.getElementById("target"), document.getElementById("source"), true);
};
document.getElementById("target2Src").onclick = function() {
sureTransfer(document.getElementById("target"), document.getElementById("source"), false);
};
document.getElementById("src2TargetAll_1").onclick = function() {
	sureTransfer(document.getElementById("source"), document.getElementById("target_1"), true);
	};
	document.getElementById("src2Target_1").onclick = function() {
	sureTransfer(document.getElementById("source"), document.getElementById("target_1"), false);
	};
	document.getElementById("target2SrcAll_1").onclick = function() {
	sureTransfer(document.getElementById("target_1"), document.getElementById("source"), true);
	};
	document.getElementById("target2Src_1").onclick = function() {
	sureTransfer(document.getElementById("target_1"), document.getElementById("source"), false);
	};
}
</script>
</head>
<body>
	<table>
		<tr>
		
			<td>
			
			<s:form action="qb_columns">
				
						<s:select size="14"
                                        name="menu"
                                        headerKey="1"
                                        list="#{'01':'Batch','02':'Course','03':'Department','04':'Degree','05':'Student','06':'Staff','07':'Hostel','08':'Book','09':'Placements'}">
                                    	
                                    </s:select> &emsp;
                                    <s:submit value=">>"></s:submit>
                                    
				</s:form>
				
                           
			</td>
			
			<td>
			
				<select id="source" name="source" multiple size="14">
				<s:iterator value="columns">
					
					<option value="<s:property value="num"/>"><s:property value="column_name"/></option> <br>
				</s:iterator>
				
			
				</select>
			
			</td>
			<td>
				<table>
					<tr>
						<td valign="top">
							<input type="button" id="src2TargetAll" name="src2TargetAll" value=">>"/><br/>
							<input type="button" id="src2Target" name="src2Target" value=">"/><br/>
							<input type="button" id="target2Src" name="target2Src" value="<"/><br/>
							<input type="button" id="target2SrcAll" name="target2SrcAll" value="<<"/><br/>
						</td>
						<td>
								<select id="target" name="target" multiple size="6">
								</select>
								
						</td>
					</tr>
					<tr><td colspan="2"><hr></td></tr>
					<tr>
						<td valign="bottom">
							<input type="button" id="src2TargetAll_1" name="src2TargetAll_1" value=">>"/><br/>
							<input type="button" id="src2Target_1" name="src2Target_1" value=">"/><br/>
							<input type="button" id="target2Src_1" name="target2Src_1" value="<"/><br/>
							<input type="button" id="target2SrcAll_1" name="target2SrcAll_1" value="<<"/><br/>
						</td>
						<td>
							<select id="target_1" name="target_1" multiple size="6">
								</select>
								
						</td>
					</tr>
				</table>
			</td>
			<td>
			<s:url action="qb_submit" id="url1"></s:url>
				<s:a href="%{url1}">Submit</s:a>
			</td>
			<tr>
	</table>
</body>
</html>